# -*- coding: utf-8 -*-
"""
Created on Thu May 26 14:44:29 2022

@author: zhao
"""

from scipy.special import eval_legendre #导入勒让德函数，用 lpmv(m,v,x) P^m_v 函数替代也可以
import numpy as np
import matplotlib.pyplot as plt
import scienceplots

plt.style.use('science') # 这个需要单独安装
plt.figure(1,dpi=300)  
x=np.linspace(-1,1,100)
for n in range(5):
    plt.plot(x, eval_legendre(n,x),linewidth = '0.7',label='$l$='+str(n)) 

plt.plot(x,np.zeros(100),linewidth = '0.1',color='black') 
plt.title('Legendre polynomials')
plt.xlabel('$x$')
plt.ylabel('$P_l(x)$')
#plt.legend(loc='upper right')
plt.legend()
name='Legendre.png'

plt.savefig(name,dpi=300)
plt.show() 